import java.awt.BorderLayout;
import java.awt.Color;
import java.io.Serializable;

import javax.swing.ComboBoxEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;




public class TeamFrame extends JFrame implements Serializable
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JComboBox colors;
	private JTextField teamName;
	private int teamNumber;
	
	public TeamFrame (Color [] colorArray, int teamNumber)
	{
		this.setLayout(null);
		JLabel nameLabel = new JLabel("Team Name:");
		nameLabel.setBounds(20, 20, 80, 20);
		this.add(nameLabel);
		
		JLabel idLabel = new JLabel("Team ID:");
		idLabel.setBounds(20, 50, 80, 20);
		this.add(idLabel);
		
		JLabel colorLabel = new JLabel("Team Color:");
		colorLabel.setBounds(20, 80, 80, 20);
		this.add(colorLabel);
		
		colors = new JComboBox(colorArray);
		
		teamName = new JTextField();
		teamName.setBounds(110,20,150,20);
		
		JTextField idText = new JTextField();
		idText.setEnabled(false);
		idText.setText("" + teamNumber);
		idText.setBounds(110, 50, 40, 20);
		this.add(idText);
		
		JButton addButton = new JButton("Add Team");
		addButton.setBounds(110, 110, 100, 30);
		this.add(addButton);
		
		this.setTitle("Add Team");
		
		colors.setEditable(true);
	    colors.setEditor(new ColorComboBoxEditor(Color.RED));
	    
	    
	    
	    
	    colors.setMaximumRowCount(5);
	    //colors.setEditable(true);
	    colors.setRenderer(new ColorCellRenderer());
	    Color color = (Color) colors.getSelectedItem();
	    ComboBoxEditor editor = new ColorComboBoxEditor(color);
	    colors.setEditor(editor);
	    colors.setBounds(110, 80, 100, 30);
	    
	    
	    
	    
	    this.add(colors);
	    this.add(teamName);
	}
	
	public static void main(String[]args)
	{
		Color [] colorArray = { Color.RED, Color.BLUE, Color.BLACK, Color.WHITE };
		TeamFrame frame = new TeamFrame(colorArray,3);
		frame.setSize(300, 200);
	    frame.setVisible(true);
		
	}

}
